package cn.shengchao.examstar.knowledge.domain.enums;

import lombok.Getter;

/**
 * 知识点掌握程度枚举
 */
@Getter
public enum MasteryLevel {
    
    EXPERT("S", "精通"),
    PROFICIENT("A", "掌握"),
    UNDERSTOOD("B", "理解"),
    BASIC("C", "初步了解"),
    UNTESTED("N", "未检测");
    
    private final String code;
    private final String description;
    
    MasteryLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    /**
     * 根据编码获取掌握程度枚举
     * 
     * @param code 编码
     * @return 掌握程度枚举
     */
    public static MasteryLevel fromCode(String code) {
        if (code == null) {
            return UNTESTED;
        }
        
        for (MasteryLevel level : MasteryLevel.values()) {
            if (level.code.equals(code)) {
                return level;
            }
        }
        
        return UNTESTED;
    }
    
    /**
     * 获取掌握程度描述
     * 
     * @param code 编码
     * @return 描述
     */
    public static String getDescriptionByCode(String code) {
        return fromCode(code).getDescription();
    }
} 